#页面类
from Day16zy.Base import Base
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from time import sleep
class Page(Base):
    #定位器
    search_loc=(By.NAME,'key')
    #页面元素的封装
    #登录
    dl = (By.XPATH,'//*[@id="root"]/div/div[1]/div[2]/div/span[2]')
    # 点击账号密码登录
    user = (By.XPATH,'//*[@id="root"]/div/div[2]/div[1]/div[1]/span[1]')
    # 输入账号
    username=(By.ID,'text')
    # 输入密码
    passwoed=(By.NAME,'password')
    # 点击登录
    button=(By.XPATH,'//*[@id="root"]/div/div[2]/div[1]/div[2]/div[2]')

    def search(self):
        #登录
        self.click(self.dl)
        sleep(5)
        # 进入框架
        frname = self.driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/iframe')
        self.driver.switch_to.frame(frname)
        sleep(5)
        # 账号密码登录
        self.click(self.user)
        sleep(5)
        # 输入账号
        self.send_keys(self.username,'17733058407')
        sleep(2)
        # 输入密码
        self.send_keys(self.passwoed, 'Li10140910')
        sleep(2)
        # 点击登录按钮
        self.click(self.button)
        sleep(10)

    #业务逻辑
    def luoji_jiuxian_01(self):
        self.open_url('https://v.ifeng.com/')
        self.search()
        sleep(5)